version 16
set more off

***************************************************************************************************
*THIS FILE PRODUCES FIGURE IV OF SLEMROD-REHMAN-WASEEM-2020, RESTAT
***************************************************************************************************

/* BI-YEARLY AVERAGES */

use				"$project_data\ITRM_Dislo_Unique_Top1000.dta", clear
g					y2=0
replace			y2=2006 if year==2007 | year==2008 | year==2008
replace			y2=2009 if year==2009 | year==2010 | year==2011
replace			y2=2012 if year==2012 | year==2013 | year==2014
keep				rank ttype year logdelT y2
g					tbins=ceil(rank/20)
replace			tbins=tbins*20
bys				tbins y2:egen avgdelT=mean(logdelT) 
duplicates		drop tbins y2, force
#d					;
twoway  			(connected  avgdelT tbins if  y2==2006 & tbins>20 & tbins<=300,sort clcolor(green) mcolor(green) msymbol(o) lwidth(thick))
					(connected  avgdelT tbins if  y2==2009 & tbins>20 & tbins<=300,sort clcolor(midblue) mcolor(midblue) msymbol(o) lwidth(thick))
					(connected  avgdelT tbins if  y2==2012 & tbins>20 & tbins<=300,sort clcolor(red) mcolor(red) msymbol(S) lwidth(thick)),
					xtitle(Rank in Year {it:t}) xtitle(, alignment(top))
					xlabel(40(20)300) ylabel(-2(1)1)
					xline(100, lcolor(gs9) lwidth(thick) lpattern(longdash))
					ytitle(Average Log Change in Tax Paid) yscale(titlegap(*10))
					legend(region(style(none)) label(1 "2006-08") label(2 "2009-11")
					label(3 "2012-14") rows(1)) 
					graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
graph 			export "$project_output\StatusSignalling_Raw.eps", replace;
#d					cr

/* YEARLY AVERAGES */

use				"$project_data\ITRM_Dislo_Unique_Top1000.dta", clear
g					after=year>=2012
keep				rank ttype year logdelT after 
g					tbins=ceil(rank/20)
replace			tbins=tbins*20
bys				tbins after:egen avgdelT=mean(logdelT) 
duplicates		drop tbins after, force
#d					;
twoway  			(connected  avgdelT tbins if  after==1 & tbins>20 & tbins<=300,sort clcolor(red) mcolor(red) msymbol(S) lwidth(thick))
					(connected  avgdelT tbins if  after==0 & tbins>20 & tbins<=300,sort clcolor(midblue) mcolor(midblue) msymbol(O) lwidth(thick)),
					xtitle(Rank in Year {it:t}) xtitle(, alignment(top))
					xlabel(40(20)300) ylabel(-2(1)1)
					xline(100, lcolor(gs9) lwidth(thick) lpattern(longdash))
					ytitle(Average Log Change in Tax Paid) yscale(titlegap(*10))
					legend(region(style(none)) label(1 "Post-Reform") label(2 "Pre-reform")
					rows(1) order(2 1)) 
					graphregion(fcolor(white) style(none) color(white) margin(0 2 0 2)) bgcolor(white);
graph 			export "$project_output\StatusSignalling_Raw2.eps", replace;
